package com.atguigu.xiaozhi.controller;

import com.atguigu.xiaozhi.assistant.XiaozhiAgent;
import com.atguigu.xiaozhi.bean.ChatForm;
import com.sun.source.doctree.SummaryTree;
import dev.langchain4j.service.spring.AiService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import static dev.langchain4j.service.spring.AiServiceWiringMode.EXPLICIT;

/**
 * @author kkdulx
 * @date 2025/10/27
 */

@Tag(name = "硅谷小智")
@RestController
@RequestMapping("/xiaozhi")

public class XiaozhiController {
    @Autowired
    private XiaozhiAgent xiaozhiAgent;

    @Operation(summary = "对话")
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm)  {
        return xiaozhiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage() );
    }
}
